<script type="text/javascript">
$(document).ready(function() {
    var initial_width;
    $('#sysconfig_table').jqGrid({
        url: '/grid_sysconfig',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['编号', '模块', '键', '值', '描述', '创建时间', '[[ "label operation"|translate ]]'],
        colModel: [{
            name: 'id',
            index: 'id',
            width: 5,
            align: 'left',
            hidden: true
        }, {
            name: 'module',
            index: 'module',
            width: 5,
            align: 'left'
        }, {
            name: 'key',
            index: 'key',
            width: 6,
            align: 'left',
            formatter: function(cellvalue, option, row) {
                return '<a href="#" onclick="detail_open(\'' + option.gid + '\',\'' + option.rowId + '\')">' + cellvalue + '</a>';
            },
            unformat: function(cellvalue) {
                return cellvalue;
            }
        }, {
            name: 'value',
            index: 'value',
            width: 6,
            align: 'left'
        }, {
            name: 'description',
            index: 'description',
            width: 6,
            align: 'left'
        }, {
            name: 'created_at',
            index: 'created_at',
            width: 6,
            align: 'left',
            hidden: true
        }, {
            name: 'operation',
            index: 'operation',
            width: 6,
            align: 'left',
            formatter: function(cellvalue, option, row) {
                var html = '';
                html += '<button style="margin-left:10px;" title="编辑" class="btn btn-blue" onclick=sysconfig_update(' + row[0] + ')>编辑</button>';
                return html;
            }
        }],
        page: 1,
        rowNum: 10,
        multiselect: true,
        multiboxonly:true,
        multiselectWidth:'60px',
        sortname: 'id',
        sortorder: 'desc',
        viewrecords: true,
        autowidth: true,
        beforeSelectRow:function(rowid, e) {
            if($(e.target).is('input')) {
                return true;
            }
            return false;
        },
        gridComplete: function() {
            var gridData = $(this).jqGrid('getRowData');
            jqgrid_page($(this), gridData);
            jqgrid_resize($(this));
        },
        resizeStart: function() {
            initial_width = $(this).width();
        },
        resizeStop: function() {
            $(this).width(initial_width);
            $(".ui-jqgrid-hbox").find('.ui-jqgrid-htable').width(initial_width);
        }
    });
});

function sysconfig_update(config_id) {
    angular.element("#sysconfig_controller").scope().open('/sysconfig_update?config_id=' + config_id)
}
</script>
<div class="panel panel-f-style">
    <div class="panel-body">
        <div class="title-tag">
            <h3>设置</h3>
            <p>系统设置</p>
        </div>
        <div class="grid-tools">
            <div class="grid-operate pull-left">
                <button id="sysconfig_controller" ng-controller="SysconfigModalCtrl" ng-show="false"></button>
            </div>
        </div>
        <div class="grid-body" id="div_grid_sysconfig_table">
            <table id="sysconfig_table"></table>
        </div>
    </div>
</div>
